<template>
	<view class="page">
		<view class="searchBox">
			<view class="inputBox">
				<view class="inputRow">
					<view class="label">
						{{language.consumeRecord.label1}}:
					</view>
					<view :class="params.createDate_begin ? 'val' : 'emty'" @click="createDate_beginShow=true">
						{{params.createDate_begin ? params.createDate_begin : language.consumeRecord.tip }}
					</view>
				</view>
				<view class="inputRow">
						<view class="label">
							{{language.consumeRecord.label2}}:
						</view>
						<view :class="params.createDate_end ? 'val' : 'emty'" @click="createDate_endShow=true">
							{{params.createDate_end ? params.createDate_end : language.consumeRecord.tip }}
						</view>
				</view>
			</view>
			<view class="btnBox">
				<view class="btn"  @click="goSearch">
					{{language.consumeRecord.search}}
				</view>
			</view>
			
		</view>
	
	<scrollYBox styleText="height: calc( 100vh - 240rpx );" @scrolltolower="scrolltolower" @handleRefresher="handleRefresher" :list="list">
				<template>
					<view style="padding-bottom: 50rpx;">
						<view class="boxItem" v-for="(item,index) in list" :key="index">
							<view class="row flex">
								<view class="item ">
									<view class="label">
										{{language.consumeRecord.label3}}
									</view>
									<view class="val">
										{{item.subsidyPayAmount | emptyStr }}
									</view>
								</view>
								<view class="item ">
									<view class="label">
										{{language.consumeRecord.label4}}
									</view>
									<view class="val">
										{{item.accountPayAmount | emptyStr }}
									</view>
								</view>
							</view>
							<view class="row flex">
								<!-- <view class="item ">
									<view class="label">
										{{language.consumeRecord.label5}}
									</view>
									<view class="val">
										{{item.amount | emptyStr }}
									</view>
								</view> -->
								<view class="item ">
									<view class="label">
										{{language.consumeRecord.label6}}
									</view>
									<view class="val">
										{{item.createDate | emptyStr }}
									</view>
								</view>
							</view>
						</view>
					</view>
				</template>
			</scrollYBox>
		<u-datetime-picker
		    :show="createDate_beginShow" ref="datetimePicker" v-model="createDate_begin" 
		    mode="date"  @cancel="createDate_beginShow=false" @confirm="createDate_beginConfirm"
		       ></u-datetime-picker>
		<u-datetime-picker
			:show="createDate_endShow" ref="datetimePicker" v-model="createDate_end" 
			mode="date"  @cancel="createDate_endShow=false" @confirm="createDate_endConfirm"
	       ></u-datetime-picker>
	</view>
</template>

<script>
	import {cardtransListApi} from '@/common/api/commonApi/consumeApi.js'
	export default {
		data() {
			return {
				list:[	],
				params:{
					mainframeNo : '',
					pageNo : 1,
					pageSize : 15,
					memberNo : '',
					createDate_begin : '',
					createDate_end : '',
				},
				createDate_begin: Number(new Date()),
				createDate_end: Number(new Date()),
				createDate_beginShow : false,
				createDate_endShow : false,
				total : 0,
			}
		},
		components:{
		},
		methods: {
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.pageNo ++
				this.getList()
			},
			goSearch(){
				this.params.pageNo = 1 
				this.getList()
			},
			createDate_beginConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.createDate_begin = date
				console.log(this.params.createDate_begin);
				this.createDate_beginShow = false
			},
			createDate_endConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.createDate_end = date
				this.createDate_endShow = false
			},
			getList(){
				let params = this.params
				if(!params.createDate_end) delete params.createDate_end
				if(!params.createDate_begin) delete params.createDate_begin
				cardtransListApi(params).then(res=>{
					if(params.pageNo==1) this.list = []
					this.list = this.list.concat(res.result.records)
					this.total = res.result.total
				})
			},
			goSearch(){
				this.params.pageNo = 1
				this.getList()
			}
			
		},
		onLoad() {
			this.setPageTitle(this.language.consumeRecord.title)
			let info = uni.getStorageSync('selectInfoAccount')
			this.params.mainframeNo = info.mainframeNo
			this.params.remberNo = info.memberNo
			this.getList()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f1f1f1;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.boxItem{
			background-color: #fff;
			margin: 20rpx;
			border-radius: 8rpx;
			padding: 10rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(102,102,102,0.15);
			.row{
				margin: 10rpx;
				display: flex;
				.item{
					width: 50%;
					// flex: 1;
				}
				.label{
					color: #969696;
				}
				.val{
					color: #353535;
					font-size: 32rpx;
				}
				.btn{
						padding: 0 30rpx;
						// width: 110rpx;
						height: 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						background: #1890ff;
						border-radius: 8rpx;
						color: #fff;
				}
			}
		}
}
</style>
